home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dc1 / stmt.h < prev    next >
Text File  |  1997-09-09  |  5KB  |  177 lines

  1.  
  2. /*
  3.  *  DC1/STMT.H
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. /*
  11. **      $Filename: stmt.h $
  12. **      $Author: dice $
  13. **      $Revision: 30.0 $
  14. **      $Date: 1994/06/10 18:04:57 $
  15. **      $Log: stmt.h,v $
  16.  * Revision 30.0  1994/06/10  18:04:57  dice
  17.  * .
  18.  *
  19.  * Revision 1.3  1993/09/19  13:03:16  jtoebes
  20.  * Fixed BUG00148 - Compiler does not catch gotos to non-existent label.
  21.  * Changed intermediate gotolabel information to know more about the label.
  22.  *
  23.  * Revision 1.2  1993/09/11  16:11:53  jtoebes
  24.  * Fixed BUG01010 - Code not allowed in switch statement before the first case.
  25.  * Added place in statement structure to hold the orphaned code.
  26.  *
  27. **/
  28.  
  29. #define st_Func     Hdr.Func
  30. #define st_Tok        Hdr.Tok
  31. #define st_Next     Hdr.Next
  32. #define st_LexIdx   Hdr.LexIdx
  33.  
  34. typedef struct StmtHdr {
  35.     void    (*Func)(void *);
  36.     short   Tok;
  37.     ubyte   Reserved1;
  38.     ubyte   Reserved2;
  39.     long    LexIdx;
  40.     struct Stmt *Next;
  41. } StmtHdr;
  42.  
  43. typedef struct Stmt {
  44.     StmtHdr Hdr;
  45. } Stmt;
  46.  
  47. /*
  48.  *  Sub statements.  Note that labels are allocated at parse time whether or
  49.  *  not they are used.    Normally the statement generator will insert conditional
  50.  *  branch nodes into the condition expressions and/or generate it's own
  51.  *  expression to handle branch to the beginning of a loop, for example.
  52.  */
  53.  
  54. typedef struct ExpStmt {
  55.     StmtHdr Hdr;
  56.     struct Exp    *Expr;
  57. } ExpStmt;
  58.  
  59. typedef struct DeclStmt {
  60.     StmtHdr Hdr;
  61.     struct Var    *Var;
  62. } DeclStmt;
  63.  
  64. typedef struct LabelStmt {
  65.     StmtHdr Hdr;
  66.     long    Label;
  67.     Stmt    *Stmt1;        /*    a: stmt, stmt is optional   */
  68. } LabelStmt;
  69.  
  70.  
  71. typedef struct ForStmt {
  72.     StmtHdr Hdr;
  73.     struct BlockStmt *Block;
  74.     Stmt    *Stmt0;    /*  available for initial jump    */
  75.     Stmt    *Stmt1;    /*  init    */
  76.     Stmt    *Stmt2;    /*  exp     */
  77.     Stmt    *Stmt3;    /*  stmt    */
  78.     Stmt    *Stmt4;    /*  code    */
  79.  
  80.     long    LabelBegin;
  81. } ForStmt;
  82.  
  83. typedef struct WhileStmt {
  84.     StmtHdr Hdr;
  85.     struct BlockStmt *Block;
  86.     Stmt    *Stmt0;    /*  available for initial jump    */
  87.     Stmt    *Stmt1;    /*  really an exp   */
  88.     Stmt    *Stmt2;    /*  code    */
  89. } WhileStmt;
  90.  
  91. typedef struct DoStmt {
  92.     StmtHdr Hdr;
  93.     struct BlockStmt *Block;
  94.     Stmt    *Stmt0;    /*  available for initial jump    XXX */
  95.     Stmt    *Stmt1;    /*  code    */
  96.     Stmt    *Stmt2;    /*  test    */
  97. } DoStmt;
  98.  
  99. typedef struct IfStmt {
  100.     StmtHdr Hdr;
  101.     Stmt    *Stmt1;    /*  cond        */
  102.     Stmt    *StmtT;    /*  if true        */
  103.     Stmt    *StmtF;    /*  if false/NULL   */
  104.     long    LabelIf;
  105.     long    LabelElse;
  106.     long    LabelEnd;
  107. } IfStmt;
  108.  
  109. /*
  110.  *  Some confusion may occur as to why CaseAry and DefStmt pointer to a
  111.  *  pointer to the statement.  This occurs because at the time of the
  112.  *  case or default label we do not yet have a statement list for it, but
  113.  *  we DO have a pointer to where that statement list will begin.
  114.  */
  115.  
  116. typedef struct SwitchStmt {
  117.     StmtHdr Hdr;
  118.     struct BlockStmt *Block;
  119.     Stmt    *Stmt1;        /*  switch exp            */
  120.     long    NumCases;        /*  number of cases        */
  121.     long    DefCaseNo;        /*  default case insertion  */
  122.     long    *Cases;        /*  switch constants        */
  123.     struct BlockStmt **CaseAry; /*  cases for switch        */
  124.     struct BlockStmt *DefBlock; /*  case for default/NULL   */
  125.     struct BlockStmt *BeforeBlock; /*  Code which appears before any case   */
  126.     long    *Labels;        /*  label id's              */
  127. } SwitchStmt;
  128.  
  129. typedef struct ReturnStmt {
  130.     StmtHdr Hdr;
  131.     Stmt    *Stmt1;        /*    return expression    */
  132. } ReturnStmt;
  133.  
  134. typedef struct BreakPointStmt {
  135.     StmtHdr Hdr;
  136. } BreakPointStmt;
  137.  
  138. typedef struct GotoStmt {
  139.     StmtHdr Hdr;
  140.     SemInfo *GotoLabel;
  141. } GotoStmt;
  142.  
  143. typedef struct ContinueStmt {
  144.     StmtHdr Hdr;
  145.     long    ContLabel;
  146. } ContinueStmt;
  147.  
  148. typedef struct BreakStmt {
  149.     StmtHdr Hdr;
  150.     long    BreakLabel;
  151. } BreakStmt;
  152.  
  153. #define BT_PROC     1
  154. #define BT_BLOCK    2
  155. #define BT_FOR        3
  156. #define BT_WHILE    4
  157. #define BT_DO        5
  158. #define BT_SWITCH   6
  159.  
  160. typedef struct BlockStmt {
  161.     StmtHdr Hdr;
  162.     short   Bid;
  163.     short   Reserved1;
  164.     Frame   Frame;        /*    allocation frame        */
  165.     struct BlockStmt *Parent;
  166.     struct Var    *VarBase;   /*    variables declared in block */
  167.     struct Var    **LastVar;
  168.     struct Stmt *Base;        /*    first statement in list     */
  169.     struct Stmt **Last;     /*    last statement in list        */
  170.  
  171.     long    LabelLoop;
  172.     long    LabelTest;
  173.     long    LabelBreak;
  174.     long    LastLexIdx;        /*  lexical index terminating block */
  175. } BlockStmt;
  176.  
  177.